package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DzZaixianMapper;
import com.ruoyi.system.domain.DzZaixian;
import com.ruoyi.system.service.IDzZaixianService;


import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.mapper.DzHuiyuanMapper;
import com.ruoyi.system.domain.DzHuiyuan;
import com.ruoyi.system.service.IDzHuiyuanService;

/**
 * 在线记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-09-28
 */
@Service
public class DzZaixianServiceImpl implements IDzZaixianService 
{
    @Autowired
    private DzZaixianMapper dzZaixianMapper;

    @Autowired
    private ISysRoleService sysRoleService;

    @Autowired
    private IDzHuiyuanService dzHuiyuanService;

    /**
     * 查询在线记录
     * 
     * @param zxId 在线记录主键
     * @return 在线记录
     */
    @Override
    public DzZaixian selectDzZaixianByZxId(Long zxId)
    {
        return dzZaixianMapper.selectDzZaixianByZxId(zxId);
    }

    /**
     * 查询在线记录列表
     * 
     * @param dzZaixian 在线记录
     * @return 在线记录
     */
    @Override
    public List<DzZaixian> selectDzZaixianList(DzZaixian dzZaixian)
    {

        //权限控制
//        SysUser user=  SecurityUtils.getLoginUser().getUser();
//        List<SysRole> listRole= sysRoleService.selectRolesByUserId(user.getUserId());
//        int datascope = 5;
//        for(SysRole role:listRole){
//            if( role.getDataScope()!=null&&Integer.parseInt(role.getDataScope())<datascope){
//                datascope=Integer.parseInt(role.getDataScope());
//            }
//        }
//        dzZaixian.setDatascope(datascope);
//        if(datascope==4){
//            dzZaixian.setCheckDeptId(user.getDeptId());
//        }
//        if(datascope==5){
//            DzHuiyuan huiyuan =  dzHuiyuanService.selectDzHuiyuanByDn(user.getPhonenumber());
//            if(huiyuan!=null){
//                dzZaixian.setCheckHuiyuanId(huiyuan.getId());
//            }else{
//                dzZaixian.setCheckHuiyuanId(0l);
//            }
//
//        }
        return dzZaixianMapper.selectDzZaixianList(dzZaixian);
    }

    @Override
    public List<DzZaixian> selectDzZaixianListWeb(DzZaixian dzZaixian)
    {
        return dzZaixianMapper.selectDzZaixianList(dzZaixian);
    }

    /**
     * 新增在线记录
     * 
     * @param dzZaixian 在线记录
     * @return 结果
     */
    @Override
    public int insertDzZaixian(DzZaixian dzZaixian)
    {
        return dzZaixianMapper.insertDzZaixian(dzZaixian);
    }

    /**
     * 修改在线记录
     * 
     * @param dzZaixian 在线记录
     * @return 结果
     */
    @Override
    public int updateDzZaixian(DzZaixian dzZaixian)
    {
        return dzZaixianMapper.updateDzZaixian(dzZaixian);
    }

    /**
     * 批量删除在线记录
     * 
     * @param zxIds 需要删除的在线记录主键
     * @return 结果
     */
    @Override
    public int deleteDzZaixianByZxIds(Long[] zxIds)
    {
        return dzZaixianMapper.deleteDzZaixianByZxIds(zxIds);
    }

    /**
     * 删除在线记录信息
     * 
     * @param zxId 在线记录主键
     * @return 结果
     */
    @Override
    public int deleteDzZaixianByZxId(Long zxId)
    {
        return dzZaixianMapper.deleteDzZaixianByZxId(zxId);
    }
}
